package com.demo.function.utils;

import lombok.Data;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;

@Data
public class Menu implements TreeNode {

    private Integer id;
    private Integer parentId;
    private String name;
    private int level;
    private List<Menu> children;

    @Override
    public Object getChildKey() {
        return id;
    }

    @Override
    public Object getParentKey() {
        return parentId;
    }

    @Override
    public Collection getChildren() {
        if (children == null) {
            children = new ArrayList<>();
        }
        return children;
    }
}
